﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PexMe.Core;
using PexMe.PersistentStore;

namespace PexMeHelper
{
    class PexMeDynamicDatabaseCleaner
    {
        /// <summary>
        /// Cleans the entire dynamic DB
        /// </summary>
        public void CleanAllDynamicDB()
        {
            PexMeDynamicDatabase pdb = new PexMeDynamicDatabase();

            //clean the factory suggestion store by deleting all unwanted uncovered location stores
            foreach (var fss in pdb.FactorySuggestionsDictionary.Values)
            {
                fss.locationStoreSpecificSequences.Clear();
                fss.PermanentFailedUncoveredLocations.Clear();
            }

            //Persist the new dynamic database 
            try
            {
                PexMeDumpWriter.DumpFactorySuggestionStore(pdb);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }        
    }
}
